<template>
  <div>
    依赖注入所提供的属性是非响应式的
    <button @click="getMap">getMap</button>
    <button @click="$parent.$emit('emitData')">emitData</button>
    <button @click="test">attachDatepicker</button>
  </div>
</template>

<script>
  export default {
    name: "BoundaryChild2",
    inject: ['getMap'],
    data() {
      return {
        name: 'test',
        count: 1,
        fullName: ''
      }
    },
    methods: {
      attachDatepicker(refName) {
        var picker = new String(refName)

        this.$once('hook:beforeDestroy', function () {
          console.log('before')
          picker = undefined
          console.log('after')
        })
      },
      fullNameM1() {
        this.fullName = this.name + (this.count++)
      },
      test() {
        // throw new Error('11')
        this.fullNameM1()
        this.attachDatepicker(this.fullName)
        console.log('finish')
      }
    }
  }
</script>

<style scoped>

</style>
